package com.siemens.industrial.model.partner;

import org.springframework.jdbc.core.RowMapper;

import java.util.Date;

/**
 * Created by qupen on 2016/9/18.
 */
public class DeviceState {
    private String deviceId;
    private Date time;
    private int state;
    private int statusType;
    private Date writeTime;

    private static final RowMapper<DeviceState> rowMapper = (resultSet, i) -> {
        System.out.println(resultSet.next()+":"+i);
        DeviceState deviceState = new DeviceState();
        deviceState.setDeviceId(resultSet.getString("device_id"));
        deviceState.setTime(resultSet.getTimestamp("time")==null?null:new Date(resultSet.getTimestamp("time").getTime()));
        deviceState.setState(resultSet.getInt("state"));
        deviceState.setStatusType(resultSet.getInt("status_type"));
        deviceState.setWriteTime(resultSet.getTimestamp("write_time")==null?null:new Date(resultSet.getTimestamp("write_time").getTime()));
        return deviceState;
    };

    public static RowMapper<DeviceState> getRowMapper() {
        return rowMapper;
    }

    //<editor-fold desc="getters and setters">

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public int getStatusType() {
        return statusType;
    }

    public void setStatusType(int statusType) {
        this.statusType = statusType;
    }

    public Date getWriteTime() {
        return writeTime;
    }

    public void setWriteTime(Date writeTime) {
        this.writeTime = writeTime;
    }

    //</editor-fold>
}
